package edu.scau.mis.web.controller;

import edu.scau.mis.cloth.entity.GsPayment;
import edu.scau.mis.cloth.service.GsOrderService;
import edu.scau.mis.cloth.service.GsPaymentService;
import edu.scau.mis.cloth.service.GsDeliveryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("gsPayment")
public class GsPaymentController {
    @Autowired
    private GsPaymentService gsPaymentService;
    @Autowired
    private GsOrderService gsOrderService;
    @Autowired
    private GsDeliveryService gsDeliveryService;
//    添加支付记录，对商品进行发货处理，添加出库记录
    @GetMapping("{orderId}/{payWay}")
    public void makePayment(@PathVariable("orderId") String orderId,@PathVariable String payWay){
        int money=gsOrderService.queryTotalMoney(orderId);
        gsPaymentService.insert(money,payWay,orderId);
//        获取订单数量
        int quantity=gsOrderService.queryCount(orderId);
        gsDeliveryService.insert(orderId,quantity);
    }

}
